#!/usr/bin/env node

const Koa = require('koa'),
      logger = require('./middleware/logger.js');

const app = new Koa();

// M-logger
app.use(async (ctx,next) => {  //M-logger
  const start = Date.now();
  next();
  const end = Date.now();
  log(`${ctx.method} ${ctx.path} ${end-start}ms`);
});
app.use((ctx, next)=>{// M-hello
  //ctx:上下文，next:调用下一个中间件
  ctx.body = 'hello koa';

});

app.listen(8080);


